
import { useState,useContext,createContext,useEffect } from "react";
import className from "classname";
// commentList.css 引入
import { useRef } from "react";
import { v4 as uuidV4 } from "uuid";
import * as dayjs from 'dayjs'
function ReduxIndex() {
  console.log(dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss"),"  redux 案例页面");
  const [datalist, setDatalist] = useState([])
  const [text, setText] = useState("")
  const inputRef = useRef("");
  // 组件挂载时，自动获取焦点
    const title = "redux 案例页面";
    const userId = 1;

   useEffect(()=>{
    inputRef.current.focus();
   },[])
   
   const inputChange=(e)=>{
      setText(e.target.value)
   }
    
  return (
    <div className="">
      <h2>{title}</h2> 
      <div>

        <input type="text" ref={inputRef} onChange={inputChange} placeholder="请输入" value={text}/> 
       
      </div>
      
    </div>
   
  );
}

export default ReduxIndex;
